import pygame
import time

GREY = (200, 220, 220) # Red, Green, Blue
RED  = (60, 255, 120)

pygame.init()

screen = pygame.display.set_mode((800, 600))

class Ball(object):
    def __init__(self, x, y, radius, v):
        self.x = x
        self.y = y
        self.r = radius
        self.v = v

ball = Ball(400, 300, 50, 4)

def update():
    screen.fill(GREY)

    if (ball.x + ball.r >= 800 or
        ball.x <= ball.r):
        ball.v = -ball.v
    if (ball.y + ball.r >= 600 or
        ball.y <= ball.r):
        ball.v = -ball.v

    ball.x += ball.v
    ball.y += ball.v

    pygame.draw.circle(screen, RED, (ball.x, ball.y), ball.r)

    pygame.display.flip()

going = True

while going:
    for evt in pygame.event.get():
        if evt.type == pygame.QUIT:
            going = False

    update()

    time.sleep(0.025)

pygame.quit()
